package com.ty.bigevent.mapper;

import com.ty.bigevent.model.entry.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
* @author ong char
* @description 针对表【user(用户表)】的数据库操作Mapper
* @createDate 2025-09-27 01:06:19
* @Entity com.ty.bigevent.model.entry.User
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where username = #{username}")
    User findByUsername(@Param("username") String username);

    @Insert("insert into user(username,password,create_time,update_time) values(#{username},#{password},now(),now())")
    void register(@Param("username") String username, @Param("password") String password);

    @Update("update user set nickname=#{nickname},email=#{email},update_time=#{update_time} where id=#{id}")
    void updateUser(User user);

    @Update("update user set user_pic= #{avatarUrl},update_time=now() where id= #{userId}")
    void updateUserAvatarUrl(@Param("userId") Integer userId,@Param("avatarUrl") String avatarUrl);

    @Select("select * from user where id= #{userId}")
    User findUserById(Integer userId);

    @Update("update user set password= #{newPassword},update_time=now() where id= #{userId}")
    void updateUserPassword(@Param("userId")Integer userId, @Param("newPassword") String newPassword);
}




